package day02;
//类型间的转换
public class DataTypeCastDemo {
    public static void main(String[] args) {
        //两种方式
        /*
        int a = 5;
        long b = a;//自动类型转换
        int c = (int)b;//强制类型转换

        long d = 5;
        double e = 5;
        System.out.println(e);//默认保留一位小数

        long f = 10000000000000L;
        int g = (int)f;
        System.out.println(g);//强制转换有可能发生溢出

        double h = 3.1415;
        int i = (int)h;
        System.out.println(i);//有可能丢失精度
         */

        //两点规则:
        //整数的直接量可以给byte,short,char赋值
        //byte<<short<<int<<long<<float<<double
        //      char<<int
        byte b1 = 3;
        byte b2 = 4;
        byte b3 = (byte) (b1 + b1);
        System.out.println(b3);

        System.out.println(2+2);
        System.out.println('2'+'2');//byte,short,char进行数学运算时自动转为int型运算
        System.out.println(2+'2');

        int m = 'a';
        System.out.println(m);//97，查看字符对应的码
        char n = 97;
        System.out.println(n);//a ,查看码对应的字符
    }
}
